#pragma once

#define W_CPU1		1
#define W_CPU2		2
#define W_CPU3		4
#define W_CPU4		8

/*
sean riddle's blittest requires a value of 61

-------------------------
romset   | longest period
-------------------------
blittest | 60
robotron | 4
joust    | 1
defender | 5
-------------------------
*/

#define W_LOADDEFAULT	4*61			//default frame counter reload value

class CMachine;
class CWatchdog
{
protected:
	CMachine *Owner;
	u32 FrameCounterLoad;			//frame counter reload value
	u32 FrameCounter;					//frame counter
	u32 Data;							//data
	u32 Size;							//size of data in bits
	int Enabled;						//watchdog enabled?
public:
	CWatchdog(CMachine *O,u32 S,u32 Load = W_LOADDEFAULT);
	virtual ~CWatchdog();
	void SetLoad(u32 Load);			//set counter reload value
	void Write(u32 n);				//watchdog write
	void Reset();						//reset watchdog
	void Frame();						//frame update
	void Enable();						//enable watchdog (default)
	void Disable();					//disable watchdog
};
